from django.db import models

import users.models


# Create your models here.
class CampusOrganizations(models.Model):
    name = models.CharField(
        max_length=32,
        null=False,
        blank=False
    )
    avatar = models.URLField('头像', default=(
        'https://img.qiusuo-mc.cn/media/avatar/825ed0c3b35e053013344ee5ade03458.png'
    ))
    intro = models.CharField(
        max_length=1024,
        default="这个社团很懒，还没有写上自我介绍"
    )
    accept = models.BooleanField(
        verbose_name="是否通过认证",
        default=False
    )

    def __str__(self):
        return str(self.id) + self.name


class CampusOrganizationsManager(models.Model):
    organization = models.ForeignKey(
        blank=False,
        null=False,
        to=CampusOrganizations,
        related_name="manager_set",
        on_delete=models.CASCADE,
        verbose_name="所关联的社团"
    )
    owner = models.ForeignKey(
        blank=False,
        null=False,
        to=users.models.UserInfo,
        related_name="job_set",
        on_delete=models.CASCADE,
        verbose_name="拥有者"
    )
    position = models.CharField(
        max_length=32,
        null=False,
        blank=False,
        verbose_name="职位"
    )
    intro = models.CharField(
        max_length=1024,
        default="这个人很懒，还没有写上自我介绍"
    )
    accept = models.BooleanField(
        verbose_name="是否通过认证",
        default=False
    )

    def __str__(self):
        return self.owner.username + '申请' + self.organization.name


class CampusOrganizationActivity(models.Model):
    organization = models.ForeignKey(
        blank=False,
        null=False,
        to=CampusOrganizations,
        related_name="activity_set",
        on_delete=models.CASCADE,
        verbose_name="所关联的社团"
    )

    title = models.CharField(
        max_length=128,
        null=False,
        blank=False,
    )

    post = models.URLField('宣传海报')
    content = models.TextField(
        max_length=1048576,
        blank=True,
        verbose_name=u'内容'
    )


class CampusOrganizationActivityTimeline(models.Model):
    activity = models.ForeignKey(
        blank=False,
        null=False,
        on_delete=models.CASCADE,
        to=CampusOrganizationActivity,
        related_name='timeline_set'
    )
    time = models.DateTimeField
    todo = models.CharField(
        max_length=10,
        default=''
    )
